<script setup>
import {useRoute} from "vue-router";
import {onMounted, ref} from "vue";
import logo from '../assets/logo.png'

const route = useRoute()

const jump = () => {
  let p = route.query.path
  if (!p) {
    p = ""
  } else {
    p = p.toLowerCase()
  }
  window.location.href = 'https://sonic-cloud.cn' + p
}
const sleep = time => {
  return new Promise(resolve => setTimeout(resolve, time)
  )
}
const times = ref(3)
onMounted(() => {
  sleep(1000).then(() => {
    times.value--
    sleep(1000).then(() => {
      times.value--
      sleep(1000).then(() => {
        times.value--
        jump()
      })
    })
  })
})
</script>
<template>
  <div style="height:100%;display: flex;align-items: center;justify-content: center">
    <div style="display: flow">
      <div style="display: flex;align-items: center;justify-content: center">
        <img :src="logo" width="50">
        <h3>✨For You, For Free, Forever✨</h3>
      </div>
      <h4>Sonic官方网站已迁移至新域名 https://sonic-cloud.cn ，将在{{ times }}s后为您跳转...</h4>
      <h4>Sonic official website has been migrated to the new domain name https://sonic-cloud.cn , will jump for you in
        {{ times }}s...</h4>
      <div>
        <el-button @click="jump" type="primary">马上跳转 Jump right now</el-button>
      </div>
    </div>
  </div>
</template>